package service

import (
	"gin_server/internal/model" // 请替换为实际的包路径
	"gin_server/internal/repository" // 请替换为实际的包路径
	"gin_server/internal/request" // 请替换为实际的包路径
)

// GroupService 定义group服务接口
// GroupService defines the interface for group business operations
type GroupService interface {
	// CreateGroup 创建新group
	CreateGroup(entity *model.Group) (*model.Group, error)
	
	// GetGroupByID 根据ID获取group
	GetGroupByID(id uint) (*model.Group, error)
	
	// GetAllGroup 获取所有group列表
	GetAllGroup(params *request.GroupQueryRequest) ([]*model.Group, int64, error)
	
	// UpdateGroup 更新group信息
	UpdateGroup(id uint, entity *request.GroupUpdateRequest) error
	
	// DeleteGroup 软删除group
	DeleteGroup(id uint) error

	// RestoreGroup 恢复group
	RestoreGroup(id uint) error
	
	// ForceDeleteGroup 真删除group
	ForceDeleteGroup(id uint) error
}

type groupService struct {
	repository repository.GroupRepository
}

func NewGroupService(repo repository.GroupRepository) GroupService {
	return &groupService{repository: repo}
}

func (s *groupService) CreateGroup(entity *model.Group) (*model.Group, error) {
	// 可以在这里添加业务校验逻辑
	return s.repository.Create(entity)
}

func (s *groupService) GetGroupByID(id uint) (*model.Group, error) {
	return s.repository.FindByID(id)
}

func (s *groupService) GetAllGroup(params *request.GroupQueryRequest) ([]*model.Group, int64, error) {
	return s.repository.FindAll(params)
}

func (s *groupService) UpdateGroup(id uint, entity *request.GroupUpdateRequest) error {
	// 可以在这里添加业务校验逻辑
	return s.repository.Update(id, entity)
}

func (s *groupService) DeleteGroup(id uint) error {
	// 可以在这里添加业务校验逻辑
	return s.repository.Delete(id)
}

func (s *groupService) RestoreGroup(id uint) error {
	// 可以在这里添加业务校验逻辑
	return s.repository.Restore(id)
}

func (s *groupService) ForceDeleteGroup(id uint) error {
	// 可以在这里添加业务校验逻辑
	return s.repository.ForceDelete(id)
}
